{include file="header"}
<div style="padding: 20px;" class="adminmyucms">
<form class="layui-form" action="">
  <div class="layui-form-item" >
     <span style="float: left;line-height: 38px;margin: 0 20px;">分类</span>
      <div style="width: 120px;float: left;">
       <select name="tid" lay-verify="required">
        <option value=""></option>
        <option value="1" {if condition="$id eq '1'"}selected="selected"{/if}>顶部导航</option>
        <option value="2" {if condition="$id eq '2'"}selected="selected"{/if}>底部导航</option>
        <option value="3" {if condition="$id eq '3'"}selected="selected"{/if}>友情链接</option>
        <option value="4" {if condition="$id eq '4'"}selected="selected"{/if}>个人中心导航</option>
       </select>
      </div>
      <span style="float: left;line-height: 38px;margin: 0 20px;">名称</span>
	  <input type="text" name="name" value=""  placeholder="名称" autocomplete="off" lay-verify="required" class="layui-input" style="width: 150px;float: left;">
      <span style="float: left;line-height: 38px;margin: 0 20px;">链接</span>
	  <input type="text" name="lianjie" value=""  placeholder="导航链接" autocomplete="off" lay-verify="required" class="layui-input" style="width: 250px;float: left;">
      <span style="float: left;line-height: 38px;margin: 0 20px;">排序</span>
	  <input type="number" name="px" value="1"  placeholder="排序" autocomplete="off" lay-verify="required" class="layui-input" style="width: 50px;float: left;">
     <span style="float: left;line-height: 38px;margin: 0 20px;">新窗口</span>
      <div style="width: 100px;float: left;">
       <select name="xin" lay-verify="required">
        <option value=""></option>
        <option value="1">是</option>
        <option value="0">否</option>

       </select>
      </div>
    <button style="float: left;line-height: 38px;margin: 0 20px;" class="layui-btn layui-btn-warm" lay-submit lay-filter="set-add">添加链接</button>
    </div>
</form>
 <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  <ul class="layui-tab-title">
   <a href="/admin.php/link/index/id/1.html"> <li {if condition="$id eq '1'"} class="layui-this"{/if}>顶部导航</li></a>
   <a href="/admin.php/link/index/id/2.html"> <li {if condition="$id eq '2'"} class="layui-this"{/if}>底部导航</li></a>
   <a href="/admin.php/link/index/id/3.html"><li {if condition="$id eq '3'"} class="layui-this"{/if}>友情链接</li></a>
   <a href="/admin.php/link/index/id/4.html"><li {if condition="$id eq '4'"} class="layui-this"{/if}>个人中心导航</li></a>
  </ul>
 
</div>  
 {volist name=":fun_S('link',array('tid'=>$id),'px desc','10',0)" id="vo"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$vo.id}">	
<table class="layui-table" style="width: 1200px;">
  <colgroup>
  	<col width="200">
    <col width="200">
    <col width="350">
    <col width="100">
    <col width="150">
    <col width="150">
    <col width="200">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>分类</th>
      <th>名称</th>
      <th>链接</th>
      <th>排序</th>
      <th>新窗口</th>
      <th>显示</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
    <tr>
      <td style="color: #2196f3;">     
       <select name="tid" lay-verify="required">
        <option value=""></option>
        <option value="1" {if condition="$vo['tid'] eq '1'"}selected="selected"{/if}>顶部导航</option>
        <option value="2" {if condition="$vo['tid'] eq '2'"}selected="selected"{/if}>底部导航</option>
        <option value="3" {if condition="$vo['tid'] eq '3'"}selected="selected"{/if}>友情链接</option>
       </select>
      </td>
      <td>
	  <input type="text" name="name" value="{$vo.name}"  placeholder="名称" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td>
	  <input type="text" name="lianjie" value="{$vo.lianjie}"  placeholder="导航链接" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td>
	  <input type="number" name="px" value="{$vo.px}"  placeholder="排序" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td>
      <div style="width: 100px;float: left;">
       <select name="xin" lay-verify="required">
        <option value=""></option>
        <option value="1" {if condition="$vo['xin'] eq '1'"}selected="selected"{/if}>是</option>
        <option value="0" {if condition="$vo['xin'] eq '0'"}selected="selected"{/if}>否</option>
       </select>
	  </td> 
      <td>
      <div style="width: 100px;float: left;">
       <select name="open" lay-verify="required">
        <option value=""></option>
        <option value="1" {if condition="$vo['open'] eq '1'"}selected="selected"{/if}>显示</option>
        <option value="0" {if condition="$vo['open'] eq '0'"}selected="selected"{/if}>隐藏</option>
       </select>
	  </td>
      <td>
      	<div class="layui-btn-group"  id="admin_set">
      			<button class="layui-btn layui-btn-sm layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 更新</button>
      			<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" member-name="确定要删除? " url="{:url("set/delete")}?id={$vo.id}&m=link" lay-submit lay-filter="delete" ><i class="layui-icon">&#xe640;</i> 删除</button>
        </div>
      	</td>
    </tr>
  </tbody>
</table>
</form>
{/volist} 
          <div style="text-align: center;">
            <div class="page">
            	{:fun_S('link',array('open'=>1,'tid'=>$id),'px desc','10',0)->render()}
             </div>
          </div>
<script>
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;

  //更新
  form.on('submit(set)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("link/update")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          //location.href = '{:url("index/index")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  //添加
  form.on('submit(set-add)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("link/insert")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
})
</script>
</div>  
{include file="footer"}